//
//  MoveAnnotationView.m
//  CarLifes
//
//  Created by yu on 2017/7/12.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "MoveAnnotationView.h"

@interface MoveAnnotationView ()

@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation MoveAnnotationView

- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    
    if (self.selected == selected) {
        return;
    }
    
    if (selected) {
        if (self.calloutView == nil) {
            //self.calloutView = [[MoveCalloutView alloc] initWithType:self.displayType];
            self.calloutView = [[MoveCalloutView alloc] initWithFrame:CGRectMake(0, 0, 210, 0) Type:self.displayType];
            self.calloutView.center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f,
            0);
        }
        [self addSubview:self.calloutView];
        
        self.calloutView.sd_layout
        .centerXEqualToView(self)
        .bottomSpaceToView(self, 25)
        .widthIs(210);
    }
    else
    {
        [self.calloutView removeFromSuperview];
    }
    [super setSelected:selected animated:animated];
}

- (void)setTModel:(TraceModel *)tModel
{
    _tModel = tModel;
    self.calloutView.tModel = tModel;
    CGFloat dir = [tModel.dir floatValue] / 180.0*M_PI;
    self.imageView.transform = CGAffineTransformMakeRotation(dir);
}


- (id)initWithAnnotation:(id<MAAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
        self.image = IMAGE_NAMED(@"online_location");
    }
    return self;
}


@end
